
package com.insigma.business.qrcode.common.converter;



import com.insigma.business.qrcode.soldier.dto.PlacementPbNewsBSearcher;
import com.insigma.business.qrcode.soldier.dto.PlacementPbNewsDTO;
import com.insigma.business.qrcode.soldier.dto.PlacementPbNewsInsertRequest;
import com.insigma.business.qrcode.soldier.dto.PlacementPbNewsUpdateRequest;
import com.insigma.business.qrcode.soldier.entity.PlacementPbNewsDO;
import com.insigma.business.qrcode.soldier.service.impl.PlacementPbNewsSearchRequest;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class PlacementPbNewsProviderConverter extends AbstractConverter<PlacementPbNewsDTO, PlacementPbNewsDO> {

    private final static PlacementPbNewsProviderConverter placementPbNewsConverter = new PlacementPbNewsProviderConverter();

    private PlacementPbNewsProviderConverter(){}

    
    public static PlacementPbNewsBSearcher convertRequestSO2Searcher(final PlacementPbNewsSearchRequest request){
        final PlacementPbNewsBSearcher placementPbNewsBSearcher = new PlacementPbNewsBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,placementPbNewsBSearcher);
        return placementPbNewsBSearcher;
    }

    
    public static PlacementPbNewsDO convertRequestUO2DO(final PlacementPbNewsUpdateRequest placementPbNewsUpdateRequest) {
        final PlacementPbNewsDO placementPbNewsDO = new PlacementPbNewsDO();
        BeanUtils.copyProperties(placementPbNewsUpdateRequest,placementPbNewsDO);
        
        return placementPbNewsDO;
    }

    
    public static PlacementPbNewsDO convertRequestIO2DO(final PlacementPbNewsInsertRequest placementPbNewsInsertRequest) {
        final PlacementPbNewsDO placementPbNewsDO = new PlacementPbNewsDO();
        BeanUtils.copyProperties(placementPbNewsInsertRequest,placementPbNewsDO);
        return placementPbNewsDO;
    }

    
    public static List<PlacementPbNewsDTO> convertResponseDOList2DTOList(final List<PlacementPbNewsDO> placementPbNewsDOList){
        return placementPbNewsConverter.convertGenericResponseDOList2DTOList(placementPbNewsDOList);
    }

    
    public static PlacementPbNewsDTO convertResponseDO2DTO(final PlacementPbNewsDO placementPbNewsDO){
        return placementPbNewsConverter.convertGenericResponseDO2DTO(placementPbNewsDO);
    }

    
    @Override
    protected PlacementPbNewsDTO doConvertResponseDO2DTO(PlacementPbNewsDO placementPbNewsDO) {
        final PlacementPbNewsDTO placementPbNewsDTO = new PlacementPbNewsDTO();
        try {
            BeanUtils.copyProperties(placementPbNewsDO, placementPbNewsDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return placementPbNewsDTO;
    }

}
